package day240521.p;

import java.util.Arrays;

public class Group <K ,V> {
K key;
V value;

    public Group(K key, V value) {
        this.key = this.key;
        this.value = value;
    }
    public V get(K key){
        if (key.equals(this.key)){
            return this.value;}else {
            return null;
        }

    }
    public  void set(K key , V value){
        this.key=key;
        this.value=value;

    }

    public static void main(String[] args) {
        Group<String,String> group1 =new Group<>("第一组","4人");
//        Group group2 =new Group("第二组","3人");
//        Group group3 =new Group("第三组","4人");
//        Group group4 =new Group("第四组","3人");
        group1.set("第一组","4人");
        System.out.println(group1.get("第一组"));
        m2();
        m3();
        m4();
    }
    private static void m2(){
        Group<String,Integer> group2=new Group<>("第一组",4);
        group2.set("第一组",4);
        System.out.println(group2.get("第一组"));
    }
    private  static void m3(){
        Group<Integer,Integer> group3=new Group<>(1,4);
        group3.set(1,4);
        System.out.println(group3.get(1));
    }
    private static void m4(){
        Group<Integer,Student[]>group4=new Group<>(1, new Student[]{new Student("学生1"),new Student("学生2")});
        group4.set(1,new Student[]{new Student("学生8"),new Student("学生9")});
        System.out.println(Arrays.toString(group4.get(1)));
    }
}class Student{
    String name;

    public Student(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                '}';
    }
}
